// 处理 "" null 0 undefined
export const changeParams = (val) => {
    const _type = ['0', "", null, undefined]
    return !_type.includes(val)
}
// 物资可以编辑代码
export const materailOptimizeOne = (prop, row, state) => {
    const materialCondition = ["changeNum", "usableStorage", "unusableStorage", "notUsableStorage", "notUnusableStorage"]
    const materialConditionOne = ["storemanNum", "storageAddress"]
    let flag = state;
    const { fieldProjectManager, isPush, outPutType } = row //行数据
    const matchCondition = isPush === "0" && outPutType !== "25"
    //修复阻断
    const _fixContent =(prop === "storemanName" && fieldProjectManager === "1")
    //主设备物资与辅材物资的订单均支持调整。其中主设备物资只允许调减，辅材物资允许调 
    if ((materialCondition.includes(prop) || _fixContent || materialConditionOne.includes(prop)) && matchCondition) {
        flag = true;//可以编辑
    }
    return flag;
}
export const materailOptimizeTwo = (prop, row, state) => {
    const materialCondition = ["usableStorage", "unusableStorage", "notUsableStorage", "notUnusableStorage"]
    const materialConditionOne = ["storemanNum", "storageAddress"]
    let flag = state;
    const { fieldProjectManager, isPush, outPutType, proType, ifPilotOrgId } = row //行数据
    const matchCondition = isPush === "0" && outPutType !== "25" && (proType === "1" && ifPilotOrgId === "1")
    //修复阻断
    const _fixContent =(prop === "storemanName" && fieldProjectManager === "1")
    //一码到底二期：试点单位项目特别修正需管控不允许调增与调减主设备物资
    if ((materialCondition.includes(prop) || _fixContent || materialConditionOne.includes(prop)) && matchCondition) {
        flag = false;//不可以编辑
    }
    return flag;
}
export const materailOptimizeThree = (prop, row, state) => {
    let flag = state;
    const { outPutType, proType } = row //行数据
    if (prop === "disableNotUnusableStorage" && proType === "0" && outPutType !== "25") {
        flag = true;//可以编辑
    }
    return flag;
}
export const materailOptimizeFour = (prop, row, state) => {
    let flag = state;
    const { disableNotUnusableStorage, notUnusableStorage, notUsableStorage, unusableStorage, usableStorage } = row //行数据
    const matchCondition = changeParams(disableNotUnusableStorage) || changeParams(notUnusableStorage) || changeParams(notUsableStorage) || changeParams(unusableStorage)
    if ((prop === "changeNum" && (matchCondition || changeParams(usableStorage)))) {
        flag = false;//不可以编辑
    }
    return flag
}
export const materailOptimizeFive = (prop, row, state) => {
    const materialCondition = ["usableStorage", "unusableStorage", "notUsableStorage", "notUnusableStorage", "disableNotUnusableStorage"]
    let flag = state;
    const { changeNum } = row //行数据
    if (materialCondition.includes(prop) && changeParams(changeNum)) {
        flag = false;//不可编辑
    }
    return flag
}
export const materailOptimizeSix = (prop, row, state) => {
    const materialCondition = ["storemanName", "storemanNum", "storageAddress"]
    let flag = state;
    const { notUnusableStorage, notUsableStorage
    } = row //行数据
    if ((materialCondition.includes(prop) && ((!changeParams(notUsableStorage)) && (!changeParams(notUnusableStorage))))) {
        flag = false;//不可编辑
    }
    return flag
}
export const materailOptimizeSeven = (prop, row, state) => {
    let flag = state;
    const { proType } = row //行数据
    if (prop === "changeNum" && proType === "1") {
        flag = false;//主设备不可以调增
    }
    return flag
}
export const materailOptimizeEight = (prop, row, state) => {
    const materialCondition = ["usableStorage", "unusableStorage", "notUsableStorage", "notUnusableStorage"]
    let flag = state;
    const { proType, spcalflag } = row //行数据
    //如果物资已支付，调减列不可编辑
    if (materialCondition.includes(prop) && (+spcalflag === 1) && (proType === "1")) {
        flag = false;//不可编辑
    }
    return flag
}
export const materailOptimizeNine = (prop, row, state) => {
    const {
        isRetreatConfig
    } = row //行数据
    let flag = state;
    if ((prop === "notUsableStorage" || prop === "notUnusableStorage") && isRetreatConfig === "0") {
        flag = false;//不可编辑
    }
    return flag
}


// 服务是否可以编辑
export const serviceOptimizeOne = (prop, row, state) => {
    const {
        adjustedPrice,
        changeNum,
        changePrice,
        price,
    } = row
    let flag = state;
    const matchCondition = (changeParams(changePrice)) || (changeParams(changeNum))
    if (prop === "ifChangeSer" && ((changeParams(adjustedPrice) && adjustedPrice !== price) || matchCondition)) {
        flag = false;//不可以编辑
    }
    return flag
}

export const serviceOptimizeTwo = (prop, row, state) => {
    const { ifChangeSer, ifModularization } = row //行数据
    let flag = state;
    if (ifChangeSer !== "1") {
        //IFMODULARIZATION是否模块化(1模块化 0 非模块化 -1 其他)
        if (ifModularization === "-1") {
            flag = serviceOptimizeThree(prop, row, flag)
        } else {
            //“模块化”服务类订单仅允许调整数量；
            //“非模块化”服务类订单允许调整数量或调整单价金额，两种调整方式操作人可任选一种；
            flag = serviceOptimizeFoure(prop, row, flag)
        }
    }
    return flag
}
export const serviceOptimizeThree = (prop, row, state) => {
    const { ifsb, epcServiceType } = row //行数据
    let flag = state;
    if (ifsb !== '0' && prop === "changeNum" && !(['4', '14'].includes(epcServiceType))) {
        flag = true;//可编辑
    }
    if (prop === "changePrice") {
        flag = true;//可编辑
    }
    return flag
}
export const serviceOptimizeFoure = (prop, row, state) => {
    const { ifModularization, epcServiceType } = row //行数据
    let flag = state;
    if (prop === "changeNum" && !(['4', '14'].includes(epcServiceType))) {
        flag = true;//可编辑
    }
    if (prop === "adjustedPrice" && ifModularization === "0") {
        flag = true;//可编辑
    }
    return flag
}
export const serviceOptimizeFive = (prop, row, state) => {
    const { epcServiceType } = row //行数据
    let flag = state;
    if (prop === "changePrice" && (['4', '14'].includes(epcServiceType))) {//总包类服务异常数据修改时控制只能调整金额，不能调整数量；
        flag = true;//可编辑
    }
    return flag
}
